package com.ordering.service.order.impl;

import java.util.List;

import com.ordering.constant.ResultResponse;
import com.ordering.dao.order.OrderItemDao;
import com.ordering.dao.order.impl.OrderItemDaoImpl;
import com.ordering.entity.OrderItem;
import com.ordering.service.order.OrderItemService;

public class OrderItemServiceImpl implements OrderItemService{

	OrderItemDao orderItemDao = new OrderItemDaoImpl();
	@Override
	public ResultResponse add(OrderItem orderItem) {
		ResultResponse response = new ResultResponse();
		try {
			response.setResult(orderItemDao.add(orderItem));
		} catch (Exception e) {
			response.setCode(ResultResponse.CODE_Fail);
			response.setMessage(e.getMessage());
			e.printStackTrace();
		}
		return response;
	}

	@Override
	public ResultResponse delect(OrderItem orderItem) {
		ResultResponse response = new ResultResponse();
		try {
			response.setResult(orderItemDao.delect(orderItem));
		} catch (Exception e) {
			response.setCode(ResultResponse.CODE_Fail);
			response.setMessage(e.getMessage());
			e.printStackTrace();
		}
		return response;
	}

	@Override
	public ResultResponse getAll(OrderItem orderItem) {
		ResultResponse response = new ResultResponse();
		try {
			response.setResult(orderItemDao.getAll(orderItem));
		} catch (Exception e) {
			response.setCode(ResultResponse.CODE_Fail);
			response.setMessage(e.getMessage());
			e.printStackTrace();
		}
		return response;
	}

	@Override
	public ResultResponse updateStatus(List<OrderItem> orderItemList){
		ResultResponse response = new ResultResponse();
		try {
			response.setResult(orderItemDao.updateStatus(orderItemList));
		} catch (Exception e) {
			response.setCode(ResultResponse.CODE_Fail);
			response.setMessage(e.getMessage());
			e.printStackTrace();
		}
		return response;
	}

}
